#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

#define MAX_LEN 11
//#define DEBUG

int N;
int f[MAX_LEN] = {
	1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800
};

int main() {
#if defined(DEBUG)
    copy(f, f+MAX_LEN, ostream_iterator<int>(cout, " "));
    cout << endl;
#endif

    while(cin >> N && N >= 0) {
#if defined(DEBUG)
        cout << N << endl;
#endif
		if (N == 0) {
			cout << "NO" << endl;
			continue;
		}
		for (int i = MAX_LEN-2; i >= 0 && N > 0; --i) {
			if (N - f[i] >= 0) {
				N -= f[i];
			}
		}
		if (N == 0)
			cout << "YES" << endl;
		else 
			cout << "NO" << endl;
		

    }

    return 0;
}
